<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Symbols Tables</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Symbols Tables' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../intern.html">Inter Modules</a></li><li><a href="index.html">bytecode</a></li><li><a href="index.html#2">Chapter 2: The Trees</a></li><li><b>Symbols Tables</b></li></ul></div>
<p class="purpose">To manage searchable tables of named symbols.</p>

<ul class="toc"><li><a href="2-st.html#SP1">&#167;1. Introduction</a></li><li><a href="2-st.html#SP6">&#167;6. Unnaming a symbol</a></li><li><a href="2-st.html#SP7">&#167;7. From name to symbol</a></li><li><a href="2-st.html#SP11">&#167;11. Creation by unique name</a></li><li><a href="2-st.html#SP13">&#167;13. From ID to symbol</a></li><li><a href="2-st.html#SP15">&#167;15. From symbol to ID</a></li><li><a href="2-st.html#SP18">&#167;18. URL-style symbol names</a></li><li><a href="2-st.html#SP21">&#167;21. Striking out symbols</a></li><li><a href="2-st.html#SP22">&#167;22. Logging</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Introduction.</b>A symbols table indexes the symbols available in a given package, and indexes
each symbol in two ways:
</p>

<ul class="items"><li>(a) With a dictionary for (fairly) efficient lookup by name; and
</li><li>(b) With an array for rapid lookup by ID number.
</li></ul>
<p class="commentary">Note that symbol IDs are just unsigned integers, though always integers which
exceed <span class="extract"><span class="extract-syntax">SYMBOL_BASE_VAL</span></span>. They can be interpreted only in context of the
symbols table they refer to: so, for example, the ID <span class="extract"><span class="extract-syntax">0x40000005</span></span> will mean
one thing in one package and something else in another. Note: do not change the
value of <span class="extract"><span class="extract-syntax">SYMBOL_BASE_VAL</span></span> without considering the effect on the file
compression scheme in <a href="3-iibf.html" class="internal">Inter in Binary Files</a>.
</p>

<p class="commentary">Some packages are very small. To save memory, the dictionary (a) is created
only when the number of symbols reaches <span class="extract"><span class="extract-syntax">NO_SYMBOLS_WORTH_A_DICTIONARY</span></span>; if
there are fewer than that, it's quicker to perform name searches exhaustively
anyway, so there's no real loss in speed.
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">SYMBOL_BASE_VAL</span><span class="plain-syntax"> </span><span class="constant-syntax">0x40000000</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">NO_SYMBOLS_WORTH_A_DICTIONARY</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">owning_package</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">dictionary</span><span class="plain-syntax"> *</span><span class="identifier-syntax">symbols_dictionary</span><span class="plain-syntax">; </span><span class="comment-syntax"> this is (a)</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> **</span><span class="identifier-syntax">symbol_array</span><span class="plain-syntax">; </span><span class="comment-syntax"> and this is (b)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">symbol_array_size</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">next_free_symbol_ID</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">resource_ID</span><span class="plain-syntax">; </span><span class="comment-syntax"> within the warehouse for the tree holding the package</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure inter_symbols_table is accessed in 2/pck, 3/iibf, 3/iitf and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::new</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::new</span></span>:<br/>The Warehouse - <a href="2-tw.html#SP8">&#167;8</a><br/>Inter in Binary Files - <a href="3-iibf.html#SP10_1_3_2_2">&#167;10.1.3.2.2</a></span></button><span class="plain-syntax">(</span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">resource_ID</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ST</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_package</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax"> = </span><span class="constant-syntax">16</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> **) </span><span class="identifier-syntax">Memory::calloc</span><span class="plain-syntax">(</span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">sizeof</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *), </span><span class="constant-syntax">INTER_SYMBOLS_MREASON</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;ST-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_free_symbol_ID</span><span class="plain-syntax"> = </span><span class="constant-syntax">SYMBOL_BASE_VAL</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">resource_ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">resource_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ST</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Symbols tables and inter packages correspond exactly to each other, but are
not merged into a single data structure for timing reasons (mainly in the
harder case when loading binary Inter from a file).
</p>

<p class="commentary">See <a href="2-pck.html#SP9" class="internal">InterPackage::set_scope</a> for where <span class="extract"><span class="extract-syntax">owning_package</span></span> is set. This
function is the inverse of <a href="2-pck.html#SP10" class="internal">InterPackage::scope</a>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::package</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::package</span></span>:<br/><a href="2-st.html#SP18">&#167;18</a>, <a href="2-st.html#SP22">&#167;22</a><br/>Symbols - <a href="2-sym.html#SP3">&#167;3</a><br/>Inter in Text Files - <a href="3-iitf.html#SP5_1">&#167;5.1</a><br/>Inter Data Types - <a href="3-idt.html#SP18_12">&#167;18.12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ST</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ST</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_package</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>It is legal to strike a symbol out of a table, by setting its array entry
to be null, though this must be done with great care (if there are references
to this symbol in Inter code anywhere, for example, trouble would follow).
But this means the array may contain some nulls. The following macro loops
through non-null symbols <span class="extract"><span class="extract-syntax">S</span></span> in the table <span class="extract"><span class="extract-syntax">T</span></span>; note that the second <span class="extract"><span class="extract-syntax">for</span></span> "loop"
executes once if <span class="extract"><span class="extract-syntax">S</span></span> is non-null, and not at all if it is null.
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="identifier-syntax">LOOP_OVER_SYMBOLS_TABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;(T?(T-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">):0); </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]; </span><span class="identifier-syntax">S</span><span class="plain-syntax">; </span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The following private-to-us function is an all-purpose way to access symbols
in a table by name.
</p>

<p class="commentary">If a symbol called <span class="extract"><span class="extract-syntax">name</span></span> exists, we return it; or, if <span class="extract"><span class="extract-syntax">wire_following</span></span> is set,
we follow the wiring to the symbol at the end of the cable &mdash; this is what the
<span class="extract"><span class="extract-syntax">name</span></span> actually means; the name doesn't really have a local meaning within the
package, in this case. (Note that the result is then a symbol outside the table
being searched, and therefore belonging to a different package to the one we
started in.)
</p>

<p class="commentary">If no such symbol exists, but <span class="extract"><span class="extract-syntax">create</span></span> is set, we then create it. If <span class="extract"><span class="extract-syntax">ID</span></span> is
zero, we give it the next free symbol ID within the table; otherwise we give
it exactly the id <span class="extract"><span class="extract-syntax">ID</span></span>. This is needed when loading binary Inter from a file,
and we need to make sure that we use the same IDs as those expected by that
binary code. In that situation, we keep nudging <span class="extract"><span class="extract-syntax">T-&gt;next_free_symbol_ID</span></span> upwards
as required to ensure that it ends up being equal to 1 more than the highest
symbol ID defined.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::search_inner</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::search_inner</span></span>:<br/><a href="2-st.html#SP7">&#167;7</a>, <a href="2-st.html#SP8">&#167;8</a>, <a href="2-st.html#SP9">&#167;9</a>, <a href="2-st.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">create</span><span class="plain-syntax">, </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">ID</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">wire_following</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no symbols table"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP5_1" class="named-paragraph-link"><span class="named-paragraph">Handle the empty symbol name as a special case</span><span class="named-paragraph-number">5.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP5_2" class="named-paragraph-link"><span class="named-paragraph">Look for the name in the table, and return it if it exists</span><span class="named-paragraph-number">5.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">create</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP5_3" class="named-paragraph-link"><span class="named-paragraph">Create a new symbol with this name, and return it</span><span class="named-paragraph-number">5.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5_1" class="paragraph-anchor"></a><b>&#167;5.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Handle the empty symbol name as a special case</span><span class="named-paragraph-number">5.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">create</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"cannot create a symbol with the empty name"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_2" class="paragraph-anchor"></a><b>&#167;5.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Look for the name in the table, and return it if it exists</span><span class="named-paragraph-number">5.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_SYMBOLS_TABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><span class="identifier-syntax">A</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">de</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Dictionaries::find</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">de</span><span class="plain-syntax">) </span><span class="identifier-syntax">S</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">Dictionaries::value_for_entry</span><span class="plain-syntax">(</span><span class="identifier-syntax">de</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">wire_following</span><span class="plain-syntax">) </span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-tw2.html#SP3" class="function-link"><span class="function-syntax">Wiring::cable_end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_3" class="paragraph-anchor"></a><b>&#167;5.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Create a new symbol with this name, and return it</span><span class="named-paragraph-number">5.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ID</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_free_symbol_ID</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_free_symbol_ID</span><span class="plain-syntax"> &lt;= </span><span class="identifier-syntax">ID</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_free_symbol_ID</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ID</span><span class="plain-syntax">+1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-sym.html#SP2" class="function-link"><span class="function-syntax">InterSymbol::new_for_symbols_table</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">ID</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP5_3_1" class="named-paragraph-link"><span class="named-paragraph">Add S to the array</span><span class="named-paragraph-number">5.3.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP5_3_2" class="named-paragraph-link"><span class="named-paragraph">Add S to the dictionary</span><span class="named-paragraph-number">5.3.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">next_free_symbol_ID</span><span class="plain-syntax"> - </span><span class="constant-syntax">SYMBOL_BASE_VAL</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">NO_SYMBOLS_WORTH_A_DICTIONARY</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP5_3_3" class="named-paragraph-link"><span class="named-paragraph">Make a dictionary from the whole symbols array, including the new S</span><span class="named-paragraph-number">5.3.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP5">&#167;5</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_3_1" class="paragraph-anchor"></a><b>&#167;5.3.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Add S to the array</span><span class="named-paragraph-number">5.3.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="identifier-syntax">ID</span><span class="plain-syntax"> - (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="constant-syntax">SYMBOL_BASE_VAL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"bad symbol ID index"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">new_size</span><span class="plain-syntax"> = </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">new_size</span><span class="plain-syntax">) </span><span class="identifier-syntax">new_size</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_size</span><span class="plain-syntax"> * </span><span class="constant-syntax">4</span><span class="plain-syntax">;</span>

<span class="plain-syntax">        </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> **</span><span class="identifier-syntax">enlarged</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> **)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Memory::calloc</span><span class="plain-syntax">(</span><span class="identifier-syntax">new_size</span><span class="plain-syntax">, </span><span class="reserved-syntax">sizeof</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *), </span><span class="constant-syntax">INTER_SYMBOLS_MREASON</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">new_size</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">enlarged</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] = </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">];</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">enlarged</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Memory::I7_free</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">, </span><span class="constant-syntax">INTER_SYMBOLS_MREASON</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax"> = </span><span class="identifier-syntax">new_size</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax"> = </span><span class="identifier-syntax">enlarged</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"inter symbols expansion failed"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">index</span><span class="plain-syntax">] = </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP5_3">&#167;5.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_3_2" class="paragraph-anchor"></a><b>&#167;5.3.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Add S to the dictionary</span><span class="named-paragraph-number">5.3.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Dictionaries::create</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Dictionaries::write_value</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, (</span><span class="reserved-syntax">void</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP5_3">&#167;5.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP5_3_3" class="paragraph-anchor"></a><b>&#167;5.3.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make a dictionary from the whole symbols array, including the new S</span><span class="named-paragraph-number">5.3.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Dictionaries::new</span><span class="plain-syntax">(16, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_SYMBOLS_TABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Dictionaries::create</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">, </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Dictionaries::write_value</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">, </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">), (</span><span class="reserved-syntax">void</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP5_3">&#167;5.3</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Unnaming a symbol.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::unname</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">dict_entry</span><span class="plain-syntax"> *</span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Dictionaries::find</span><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbols_dictionary</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">E</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">A</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">value</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">value</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">identifier</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">identifier</span><span class="plain-syntax">, </span><span class="string-syntax">"nameless__%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_OVER_SYMBOLS_TABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">), </span><span class="identifier-syntax">name</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">identifier</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">identifier</span><span class="plain-syntax">, </span><span class="string-syntax">"nameless__%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. From name to symbol.</b>Variations on the above then provide an API for looking up the meaning of names
within a symbols table.
</p>

<p class="commentary">First: what if anything does <span class="extract"><span class="extract-syntax">name</span></span> mean? Return <span class="extract"><span class="extract-syntax">NULL</span></span> if nothing.
</p>

<p class="commentary">This is wire-following: that is, if the answer is a symbol wired to another symbol
elsewhere in the tree, then we return that other symbol.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_name</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_name</span></span>:<br/><a href="2-st.html#SP12">&#167;12</a>, <a href="2-st.html#SP19">&#167;19</a>, <a href="2-st.html#SP20">&#167;20</a><br/>Packages - <a href="2-pck.html#SP11">&#167;11</a><br/>Transmigration - <a href="2-trn.html#SP5_1">&#167;5.1</a>, <a href="2-trn.html#SP5_2_1">&#167;5.2.1</a><br/>Inter in Text Files - <a href="3-iitf.html#SP4">&#167;4</a>, <a href="3-iitf.html#SP5">&#167;5</a>, <a href="3-iitf.html#SP5_1">&#167;5.1</a>, <a href="3-iitf.html#SP6">&#167;6</a>, <a href="3-iitf.html#SP7_1">&#167;7.1</a>, <a href="3-iitf.html#SP12_14">&#167;12.14</a><br/>Metadata - <a href="3-mtd.html#SP3">&#167;3</a><br/>The PropertyValue Construct - <a href="4-tpc7.html#SP4">&#167;4</a><br/>The Provenance Construct - <a href="4-tpc8.html#SP5">&#167;5</a><br/>The Inv Construct - <a href="5-tic.html#SP7_1">&#167;7.1</a><br/>The Lab Construct - <a href="5-tlc.html#SP4">&#167;4</a><br/>The Label Construct - <a href="5-tlc2.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP5" class="function-link"><span class="function-syntax">InterSymbolsTable::search_inner</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>The same, but not wire-following. The result might therefore be a symbol which
is wired to something elsewhere in the tree, and doesn't really have a local
meaning of its own.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_name_not_following</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_name_not_following</span></span>:<br/>Packages - <a href="2-pck.html#SP20">&#167;20</a><br/>The Wiring - <a href="2-tw2.html#SP11">&#167;11</a>, <a href="2-tw2.html#SP12">&#167;12</a>, <a href="2-tw2.html#SP14">&#167;14</a><br/>Transmigration - <a href="2-trn.html#SP3_3">&#167;3.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP5" class="function-link"><span class="function-syntax">InterSymbolsTable::search_inner</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>The same, but creating the name if it doesn't exist already.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_name_creating</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_name_creating</span></span>:<br/><a href="2-st.html#SP11">&#167;11</a><br/>Transmigration - <a href="2-trn.html#SP3_3">&#167;3.3</a>, <a href="2-trn.html#SP5_1_1">&#167;5.1.1</a>, <a href="2-trn.html#SP5_2_1_1">&#167;5.2.1.1</a><br/>Inter in Text Files - <a href="3-iitf.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP5" class="function-link"><span class="function-syntax">InterSymbolsTable::search_inner</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>Use this variant, which forces the symbol ID to a particular value, only if you
are sure you know what you're doing. It would be disastrous to use an ID already
taken.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_name_creating_at_ID</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_name_creating_at_ID</span></span>:<br/>Inter in Binary Files - <a href="3-iibf.html#SP10_1_3_2_2">&#167;10.1.3.2.2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">ID</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP5" class="function-link"><span class="function-syntax">InterSymbolsTable::search_inner</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">, </span><span class="identifier-syntax">ID</span><span class="plain-syntax">, </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. Creation by unique name.</b>Here we definitely want a new symbol, not an existing one, and if necessary
we monkey with the proposed name for it until it differs from the name of anything
already defined in the package.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::create_with_unique_name</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::create_with_unique_name</span></span>:<br/><a href="2-st.html#SP16_1_2">&#167;16.1.2</a>, <a href="2-st.html#SP20">&#167;20</a><br/>The Wiring - <a href="2-tw2.html#SP12">&#167;12</a>, <a href="2-tw2.html#SP14">&#167;14</a><br/>Inter in Text Files - <a href="3-iitf.html#SP5_1">&#167;5.1</a>, <a href="3-iitf.html#SP12_14">&#167;12.14</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP9" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name_creating</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><a href="2-st.html#SP12" class="function-link"><span class="function-syntax">InterSymbolsTable::render_identifier_unique</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>Which uses the following to construct its unique name:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::render_identifier_unique</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::render_identifier_unique</span></span>:<br/><a href="2-st.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ST</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">N</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="identifier-syntax">still_unduplicated</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">ST</span><span class="plain-syntax"> = </span><a href="2-st.html#SP7" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">)) != </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">still_unduplicated</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::duplicate</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">still_unduplicated</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">TAIL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">TAIL</span><span class="plain-syntax">, </span><span class="string-syntax">"_%d"</span><span class="plain-syntax">, </span><span class="identifier-syntax">N</span><span class="plain-syntax">++);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">Str::truncate</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">) - </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">A</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">TAIL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><span class="identifier-syntax">TAIL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Str::truncate</span><span class="plain-syntax">(</span><span class="identifier-syntax">name</span><span class="plain-syntax">, </span><span class="constant-syntax">31</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">TAIL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">name</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. From ID to symbol.</b>Symbols are represented in Inter bytecode by their ID numbers, but these only
make sense in the context of a symbols table: i.e., the same ID can have
a different meaning in one inter frame than in another. We provide two ways
to access this: one following equations, the other not.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_ID_not_following</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_ID_not_following</span></span>:<br/>Inter in Text Files - <a href="3-iitf.html#SP10">&#167;10</a><br/>Verifying Inter - <a href="3-vi.html#SP1_2">&#167;1.2</a><br/>Inter Value Pairs - <a href="3-ivp.html#SP13">&#167;13</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">ID</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="identifier-syntax">ID</span><span class="plain-syntax"> - (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="constant-syntax">SYMBOL_BASE_VAL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">index</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array_size</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">T</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">index</span><span class="plain-syntax">];</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_ID</span><button class="popup" onclick="togglePopup('usagePopup11')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup11">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_ID</span></span>:<br/><a href="2-st.html#SP14">&#167;14</a><br/>Inter in Binary Files - <a href="3-iibf.html#SP10_1_4">&#167;10.1.4</a><br/>Verifying Inter - <a href="3-vi.html#SP2">&#167;2</a>, <a href="3-vi.html#SP3">&#167;3</a>, <a href="3-vi.html#SP4">&#167;4</a><br/>Inter Value Pairs - <a href="3-ivp.html#SP13">&#167;13</a>, <a href="3-ivp.html#SP22_2">&#167;22.2</a><br/>Inter Data Types - <a href="3-idt.html#SP14">&#167;14</a><br/>The Package Construct - <a href="4-tpc.html#SP10">&#167;10</a><br/>The Provenance Construct - <a href="4-tpc8.html#SP7">&#167;7</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">ID</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-st.html#SP13" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_ID_not_following</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">ID</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-tw2.html#SP3" class="function-link"><span class="function-syntax">Wiring::cable_end</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>It's convenient to have some abbreviations for common ways to access the above.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_ID_at_node</span><button class="popup" onclick="togglePopup('usagePopup12')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup12">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::symbol_from_ID_at_node</span></span>:<br/>Inter Constructs - <a href="3-ic.html#SP19">&#167;19</a><br/>The Constant Construct - <a href="4-tcc2.html#SP8">&#167;8</a><br/>The Instance Construct - <a href="4-tic2.html#SP3">&#167;3</a>, <a href="4-tic2.html#SP6">&#167;6</a><br/>The Origin Construct - <a href="4-toc.html#SP5">&#167;5</a><br/>The Package Construct - <a href="4-tpc.html#SP9">&#167;9</a><br/>The PackageType Construct - <a href="4-tpc2.html#SP4">&#167;4</a><br/>The Permission Construct - <a href="4-tpc3.html#SP3">&#167;3</a>, <a href="4-tpc3.html#SP6">&#167;6</a><br/>The Primitive Construct - <a href="4-tpc5.html#SP5">&#167;5</a>, <a href="4-tpc5.html#SP8">&#167;8</a><br/>The Property Construct - <a href="4-tpc6.html#SP5">&#167;5</a>, <a href="4-tpc6.html#SP6">&#167;6</a><br/>The PropertyValue Construct - <a href="4-tpc7.html#SP6">&#167;6</a><br/>The Typename Construct - <a href="4-ttc.html#SP6">&#167;6</a><br/>The Variable Construct - <a href="4-tvc.html#SP6">&#167;6</a><br/>The Inv Construct - <a href="5-tic.html#SP9">&#167;9</a><br/>The Lab Construct - <a href="5-tlc.html#SP6">&#167;6</a><br/>The Label Construct - <a href="5-tlc2.html#SP6">&#167;6</a><br/>The Local Construct - <a href="5-tlc3.html#SP6">&#167;6</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP13" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_ID</span></a><span class="plain-syntax">(</span><a href="2-pck.html#SP12" class="function-link"><span class="function-syntax">InterPackage::scope_of</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">), </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">W</span><span class="plain-syntax">.</span><span class="element-syntax">instruction</span><span class="plain-syntax">[</span><span class="identifier-syntax">x</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::global_symbol_from_ID_at_node</span><button class="popup" onclick="togglePopup('usagePopup13')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup13">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::global_symbol_from_ID_at_node</span></span>:<br/>The Package Construct - <a href="4-tpc.html#SP7">&#167;7</a><br/>The Inv Construct - <a href="5-tic.html#SP9">&#167;9</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP13" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_ID</span></a><span class="plain-syntax">(</span><a href="2-in.html#SP6" class="function-link"><span class="function-syntax">Inode::globals</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">), </span><span class="identifier-syntax">P</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">W</span><span class="plain-syntax">.</span><span class="element-syntax">instruction</span><span class="plain-syntax">[</span><span class="identifier-syntax">x</span><span class="plain-syntax">]);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::symbol_from_ID_in_package</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">owner</span><span class="plain-syntax">, </span><span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="identifier-syntax">ID</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP13" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_ID</span></a><span class="plain-syntax">(</span><a href="2-pck.html#SP10" class="function-link"><span class="function-syntax">InterPackage::scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">owner</span><span class="plain-syntax">), </span><span class="identifier-syntax">ID</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. From symbol to ID.</b>If all we want is to read the ID of a symbol definitely present in the given
symbols table, that's easy. Suppose we have this example:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">       |</span>
<span class="plain-syntax">    |                 |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">example</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">another</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">        |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">3</span><span class="plain-syntax">: </span><span class="identifier-syntax">further</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    +-----------------+</span>
</pre>
<p class="commentary">Then if we want the ID of symbol <span class="extract"><span class="extract-syntax">plugh</span></span> in package <span class="extract"><span class="extract-syntax">P</span></span>, we just return 3,
its symbol ID within the table.
</p>

<p class="commentary">Here, if <span class="extract"><span class="extract-syntax">P</span></span> is null then we use the root package, and therefore the global
symbols table.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::id_from_symbol_not_creating</span><button class="popup" onclick="togglePopup('usagePopup14')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup14">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::id_from_symbol_not_creating</span></span>:<br/>The Package Construct - <a href="4-tpc.html#SP11">&#167;11</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no symbol"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP10" class="function-link"><span class="function-syntax">InterPackage::scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">T</span><span class="plain-syntax"> = </span><a href="2-it.html#SP3" class="function-link"><span class="function-syntax">InterTree::global_scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">T</span><span class="plain-syntax"> != </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_table</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Symbol is $3, owned by $4, but we wanted ID from $4\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">T</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"ID not available in this scope"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::id_from_global_symbol</span><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP15" class="function-link"><span class="function-syntax">InterSymbolsTable::id_from_symbol_not_creating</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. </b>However, things become more interesting if we do not know that the symbol
<span class="extract"><span class="extract-syntax">S</span></span> belongs to <span class="extract"><span class="extract-syntax">P</span></span>. Suppose:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    +-----------------+    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">       |    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">SP</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    |                 |    |                 |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">example</span><span class="plain-syntax">      |    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">xyzzy</span><span class="plain-syntax">        |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">another</span><span class="plain-syntax">      |    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">        |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">further</span><span class="plain-syntax">      |    |                 |</span>
<span class="plain-syntax">    +-----------------+    +-----------------+</span>
</pre>
<p class="commentary">and suppose we again want the ID for <span class="extract"><span class="extract-syntax">plugh</span></span> within package <span class="extract"><span class="extract-syntax">P</span></span>. The only way
to do this is to create a new symbol in <span class="extract"><span class="extract-syntax">P</span></span> and wire it to <span class="extract"><span class="extract-syntax">plugh</span></span>:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">       |</span>
<span class="plain-syntax">    |                 |    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">example</span><span class="plain-syntax">      |    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">SP</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">another</span><span class="plain-syntax">      |    |                 |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">further</span><span class="plain-syntax">      |    |   </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">xyzzy</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">3</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax"> ~~~~~~~~~~~~~~&gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    +-----------------+    +-----------------+</span>
</pre>
<p class="commentary">We can then return 3 as the ID of <span class="extract"><span class="extract-syntax">plugh</span></span> within <span class="extract"><span class="extract-syntax">P</span></span>.
</p>

<p class="commentary">Note that there are now two symbols named <span class="extract"><span class="extract-syntax">plugh</span></span>, one in each package. But the
new one in <span class="extract"><span class="extract-syntax">P</span></span> is a sort of reference only: it is wired to the old one in <span class="extract"><span class="extract-syntax">SP</span></span>.
To see what the new <span class="extract"><span class="extract-syntax">plugh</span></span> means, one must follow the wiring to the old <span class="extract"><span class="extract-syntax">plugh</span></span>.
But this is no real burden, because:
</p>

<ul class="items"><li>(a) A name-search by <a href="2-st.html#SP7" class="internal">InterSymbolsTable::symbol_from_name</a> on <span class="extract"><span class="extract-syntax">"plugh"</span></span> within
the package <span class="extract"><span class="extract-syntax">P</span></span> finds the new <span class="extract"><span class="extract-syntax">plugh</span></span> symbol but then follows the wiring to
the old <span class="extract"><span class="extract-syntax">plugh</span></span> in <span class="extract"><span class="extract-syntax">SP</span></span>, and returns that; and
</li><li>(b) So does ID lookup by <a href="2-st.html#SP13" class="internal">InterSymbolsTable::symbol_from_ID</a> on ID 3 within <span class="extract"><span class="extract-syntax">P</span></span>.
</li></ul>
<p class="commentary">In effect, once the following function has been used, everything will work just
as if the symbol were in <span class="extract"><span class="extract-syntax">P</span></span> after all.
</p>

<p class="commentary">Finally, note that this awkward case:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    +-----------------+    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">       |    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">SP</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    |                 |    |                 |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">        |    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">xyzzy</span><span class="plain-syntax">        |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">another</span><span class="plain-syntax">      |    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">        |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">further</span><span class="plain-syntax">      |    |                 |</span>
<span class="plain-syntax">    +-----------------+    +-----------------+</span>
</pre>
<p class="commentary">also needs to be handled: i.e., where package <span class="extract"><span class="extract-syntax">P</span></span> already contains a different
and unrelated symbol coincidentally called <span class="extract"><span class="extract-syntax">"plugh"</span></span>. In that case, we end up with:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">P</span><span class="plain-syntax">       |</span>
<span class="plain-syntax">    |                 |    +-----------------+</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">        |    | </span><span class="identifier-syntax">Package</span><span class="plain-syntax"> </span><span class="identifier-syntax">SP</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">another</span><span class="plain-syntax">      |    |                 |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="identifier-syntax">further</span><span class="plain-syntax">      |    |   </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">xyzzy</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    | </span><span class="constant-syntax">3</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh_1</span><span class="plain-syntax"> ~~~~~~~~~~~~&gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="identifier-syntax">plugh</span><span class="plain-syntax">      |</span>
<span class="plain-syntax">    +-----------------+    +-----------------+</span>
</pre>
<p class="commentary">This time, the reference symbol has been named <span class="extract"><span class="extract-syntax">"plugh_1"</span></span> to avoid a name
collision with the original <span class="extract"><span class="extract-syntax">plugh</span></span> in package <span class="extract"><span class="extract-syntax">P</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::id_from_symbol</span><button class="popup" onclick="togglePopup('usagePopup15')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup15">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::id_from_symbol</span></span>:<br/><a href="2-st.html#SP17">&#167;17</a><br/>Transmigration - <a href="2-trn.html#SP5_1_1">&#167;5.1.1</a>, <a href="2-trn.html#SP5_2_1_1">&#167;5.2.1.1</a><br/>Inter Value Pairs - <a href="3-ivp.html#SP13">&#167;13</a><br/>The Package Construct - <a href="4-tpc.html#SP4">&#167;4</a>, <a href="4-tpc.html#SP11">&#167;11</a><br/>The Provenance Construct - <a href="4-tpc8.html#SP2">&#167;2</a>, <a href="4-tpc8.html#SP3">&#167;3</a><br/>The Inv Construct - <a href="5-tic.html#SP3">&#167;3</a>, <a href="5-tic.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no symbol"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P_table</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP10" class="function-link"><span class="function-syntax">InterPackage::scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P_table</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">P_table</span><span class="plain-syntax"> = </span><a href="2-it.html#SP3" class="function-link"><span class="function-syntax">InterTree::global_scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP16" class="function-link"><span class="function-syntax">InterSymbolsTable::id_from_symbol_in_table</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::id_from_symbol_in_table</span><button class="popup" onclick="togglePopup('usagePopup16')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup16">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::id_from_symbol_in_table</span></span>:<br/>Inter Data Types - <a href="3-idt.html#SP15">&#167;15</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P_table</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no symbol"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P_table</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no table"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">SP_table</span><span class="plain-syntax"> = </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_table</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P_table</span><span class="plain-syntax"> != </span><span class="identifier-syntax">SP_table</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP16_1" class="named-paragraph-link"><span class="named-paragraph">We need an ID to a faraway symbol</span><span class="named-paragraph-number">16.1</span></a></span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16_1" class="paragraph-anchor"></a><b>&#167;16.1. </b>Because global symbols are visible everywhere, we never need local IDs for
them on a package-by-package basis, so it is an error to call this function if
<span class="extract"><span class="extract-syntax">S</span></span> is a global.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">We need an ID to a faraway symbol</span><span class="named-paragraph-number">16.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">INTER_SYMBOLS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Seek ID of $3 from $4, which is not its owner $4\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">P_table</span><span class="plain-syntax">, </span><span class="identifier-syntax">SP_table</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP16_1_1" class="named-paragraph-link"><span class="named-paragraph">If this table already has a symbol wired to that faraway symbol, fine: use that</span><span class="named-paragraph-number">16.1.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="2-st.html#SP16_1_2" class="named-paragraph-link"><span class="named-paragraph">Otherwise make a new symbol in the table and wire it to the faraway one</span><span class="named-paragraph-number">16.1.2</span></a></span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP16">&#167;16</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP16_1_1" class="paragraph-anchor"></a><b>&#167;16.1.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">If this table already has a symbol wired to that faraway symbol, fine: use that</span><span class="named-paragraph-number">16.1.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">LOOP_OVER_SYMBOLS_TABLE</span><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">P_table</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="2-tw2.html#SP2" class="function-link"><span class="function-syntax">Wiring::wired_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">E</span><span class="plain-syntax">) == </span><span class="identifier-syntax">S</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="constant-syntax">inter_ti</span><span class="plain-syntax">) </span><span class="identifier-syntax">E</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP16_1">&#167;16.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP16_1_2" class="paragraph-anchor"></a><b>&#167;16.1.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Otherwise make a new symbol in the table and wire it to the faraway one</span><span class="named-paragraph-number">16.1.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><a href="2-st.html#SP11" class="function-link"><span class="function-syntax">InterSymbolsTable::create_with_unique_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P_table</span><span class="plain-syntax">, </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><a href="2-tw2.html#SP5" class="function-link"><span class="function-syntax">Wiring::wire_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="2-st.html#SP16_1">&#167;16.1</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. </b>The same operation, but the local context expressed differently:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="constant-syntax">inter_ti</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::id_at_bookmark</span><button class="popup" onclick="togglePopup('usagePopup17')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup17">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::id_at_bookmark</span></span>:<br/>Inter Data Types - <a href="3-idt.html#SP15">&#167;15</a><br/>The Constant Construct - <a href="4-tcc2.html#SP2">&#167;2</a>, <a href="4-tcc2.html#SP4">&#167;4</a><br/>The Instance Construct - <a href="4-tic2.html#SP2">&#167;2</a><br/>The Origin Construct - <a href="4-toc.html#SP2">&#167;2</a><br/>The Package Construct - <a href="4-tpc.html#SP4">&#167;4</a><br/>The PackageType Construct - <a href="4-tpc2.html#SP2">&#167;2</a><br/>The Permission Construct - <a href="4-tpc3.html#SP2">&#167;2</a><br/>The Primitive Construct - <a href="4-tpc5.html#SP2">&#167;2</a><br/>The Property Construct - <a href="4-tpc6.html#SP2">&#167;2</a><br/>The PropertyValue Construct - <a href="4-tpc7.html#SP2">&#167;2</a><br/>The Typename Construct - <a href="4-ttc.html#SP2">&#167;2</a><br/>The Variable Construct - <a href="4-tvc.html#SP2">&#167;2</a><br/>The Inv Construct - <a href="5-tic.html#SP3">&#167;3</a><br/>The Lab Construct - <a href="5-tlc.html#SP2">&#167;2</a><br/>The Label Construct - <a href="5-tlc2.html#SP2">&#167;2</a><br/>The Local Construct - <a href="5-tlc3.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_bookmark</span><span class="plain-syntax"> *</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP16" class="function-link"><span class="function-syntax">InterSymbolsTable::id_from_symbol</span></a><span class="plain-syntax">(</span><a href="2-bkm.html#SP7" class="function-link"><span class="function-syntax">InterBookmark::tree</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><a href="2-bkm.html#SP6" class="function-link"><span class="function-syntax">InterBookmark::package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">IBM</span><span class="plain-syntax">), </span><span class="identifier-syntax">S</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. URL-style symbol names.</b>We saw in <a href="2-pck.html#SP19" class="internal">InterPackage::write_URL</a> that every package can be identified
uniquely by a URL, so that, say, <span class="extract"><span class="extract-syntax">/main/example/whatever</span></span> means the package
<span class="extract"><span class="extract-syntax">whatever</span></span> in the package <span class="extract"><span class="extract-syntax">example</span></span> in the package <span class="extract"><span class="extract-syntax">main</span></span> at the root of the tree.
</p>

<p class="commentary">As a result, symbols can also have unique URLs: <span class="extract"><span class="extract-syntax">/main/example/whatever/plugh</span></span>
means the symbol called <span class="extract"><span class="extract-syntax">plugh</span></span> which is in that package.
</p>

<p class="commentary">This is not really two different conventions. The URL for a package is the same
as the URL for the symbol of that package's name, so really we can think of URLs
for packages as a special case of URLs for symbols.
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">MAX_URL_SYMBOL_NAME_DEPTH</span><span class="plain-syntax"> </span><span class="constant-syntax">512</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::write_symbol_URL</span><button class="popup" onclick="togglePopup('usagePopup18')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup18">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::write_symbol_URL</span></span>:<br/>Symbols - <a href="2-sym.html#SP23">&#167;23</a><br/>The Wiring - <a href="2-tw2.html#SP12">&#167;12</a><br/>Inter in Text Files - <a href="3-iitf.html#SP5_2">&#167;5.2</a>, <a href="3-iitf.html#SP10">&#167;10</a><br/>Verifying Inter - <a href="3-vi.html#SP2">&#167;2</a><br/>Inter Data Types - <a href="3-idt.html#SP20">&#167;20</a><br/>The Plug Construct - <a href="6-tpc.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">chain</span><span class="plain-syntax">[</span><span class="constant-syntax">MAX_URL_SYMBOL_NAME_DEPTH</span><span class="plain-syntax">];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">chain_length</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="2-st.html#SP3" class="function-link"><span class="function-syntax">InterSymbolsTable::package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_table</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) { </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"%S"</span><span class="plain-syntax">, </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">)); </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">chain_length</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">MAX_URL_SYMBOL_NAME_DEPTH</span><span class="plain-syntax">) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"package nesting too deep"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">chain</span><span class="plain-syntax">[</span><span class="identifier-syntax">chain_length</span><span class="plain-syntax">++] = </span><span class="identifier-syntax">P</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP5" class="function-link"><span class="function-syntax">InterPackage::parent</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=</span><span class="identifier-syntax">chain_length</span><span class="plain-syntax">-1; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&gt;=0; </span><span class="identifier-syntax">i</span><span class="plain-syntax">--) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"/%S"</span><span class="plain-syntax">, </span><a href="2-pck.html#SP7" class="function-link"><span class="function-syntax">InterPackage::name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">chain</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">]));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"/%S"</span><span class="plain-syntax">, </span><a href="2-sym.html#SP19" class="function-link"><span class="function-syntax">InterSymbol::identifier</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. </b>Conversely, we parse a URL and locate the symbol it describes.
</p>

<p class="commentary">All URLs here are absolute. If no initial <span class="extract"><span class="extract-syntax">/</span></span> occurs, the URL is assumed to be
a global name: so <span class="extract"><span class="extract-syntax">/global_name</span></span> and <span class="extract"><span class="extract-syntax">global_name</span></span> both mean the same thing,
i.e., the symbol named <span class="extract"><span class="extract-syntax">global_name</span></span> in the root package. However, <span class="extract"><span class="extract-syntax">this/that</span></span>
means a symbol named <span class="extract"><span class="extract-syntax">this/that</span></span> (which cannot ever exist), not a symbol named
<span class="extract"><span class="extract-syntax">that</span></span> in a package named <span class="extract"><span class="extract-syntax">this</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::URL_to_symbol</span><button class="popup" onclick="togglePopup('usagePopup19')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup19">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::URL_to_symbol</span></span>:<br/><a href="2-st.html#SP20">&#167;20</a><br/>Inter in Text Files - <a href="3-iitf.html#SP5_1">&#167;5.1</a>, <a href="3-iitf.html#SP7_1">&#167;7.1</a><br/>The Plug Construct - <a href="6-tpc.html#SP2">&#167;2</a><br/>The Socket Construct - <a href="6-tsc.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">URL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::get_first_char</span><span class="plain-syntax">(</span><span class="identifier-syntax">URL</span><span class="plain-syntax">) == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">at_P</span><span class="plain-syntax"> = </span><span class="identifier-syntax">I</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">root_package</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">, </span><span class="identifier-syntax">URL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">at_P</span><span class="plain-syntax"> = </span><a href="2-pck.html#SP20" class="function-link"><span class="function-syntax">InterPackage::from_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">at_P</span><span class="plain-syntax">, </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at_P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">C</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP7" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name</span></a><span class="plain-syntax">(</span><a href="2-pck.html#SP10" class="function-link"><span class="function-syntax">InterPackage::scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">at_P</span><span class="plain-syntax">), </span><span class="identifier-syntax">C</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="2-st.html#SP7" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name</span></a><span class="plain-syntax">(</span><a href="2-it.html#SP3" class="function-link"><span class="function-syntax">InterTree::global_scope</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">), </span><span class="identifier-syntax">URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. </b>This variation creates a wired symbol in <span class="extract"><span class="extract-syntax">T</span></span> to the given URL if there is
currently nothing at that URL; it is used when reading in textual Inter files,
as a way of handling forward references.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="function-syntax">InterSymbolsTable::wire_to_URL</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::wire_to_URL</span></span>:<br/>Inter in Text Files - <a href="3-iitf.html#SP12_14">&#167;12.14</a><br/>Inter Data Types - <a href="3-idt.html#SP18_12">&#167;18.12</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_tree</span><span class="plain-syntax"> *</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">URL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">T</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-st.html#SP19" class="function-link"><span class="function-syntax">InterSymbolsTable::URL_to_symbol</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="plain-syntax">, </span><span class="identifier-syntax">URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">S</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TEMPORARY_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOOP_THROUGH_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">, </span><span class="identifier-syntax">URL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">inchar32_t</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Str::get</span><span class="plain-syntax">(</span><span class="identifier-syntax">pos</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> == </span><span class="character-syntax">'/'</span><span class="plain-syntax">) </span><span class="identifier-syntax">Str::clear</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">PUT_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">, </span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-st.html#SP7" class="function-link"><span class="function-syntax">InterSymbolsTable::symbol_from_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">leaf</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (!((</span><span class="identifier-syntax">S</span><span class="plain-syntax">) &amp;&amp; (</span><a href="2-tw2.html#SP7" class="function-link"><span class="function-syntax">Wiring::is_wired_to_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">)) &amp;&amp;</span>
<span class="plain-syntax">            (</span><span class="identifier-syntax">Str::eq</span><span class="plain-syntax">(</span><a href="2-tw2.html#SP7" class="function-link"><span class="function-syntax">Wiring::wired_to_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">), </span><span class="identifier-syntax">URL</span><span class="plain-syntax">)))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">S</span><span class="plain-syntax"> = </span><a href="2-st.html#SP11" class="function-link"><span class="function-syntax">InterSymbolsTable::create_with_unique_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">T</span><span class="plain-syntax">, </span><span class="identifier-syntax">leaf</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><a href="2-tw2.html#SP7" class="function-link"><span class="function-syntax">Wiring::wire_to_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">URL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">leaf</span><span class="plain-syntax">)</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">S</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. Striking out symbols.</b>This is a desperation measure. The tree may be full of references to <span class="extract"><span class="extract-syntax">S</span></span> made
by its ID: those IDs will then fail to resolve if the array entry for <span class="extract"><span class="extract-syntax">S</span></span> has
been struck out to <span class="extract"><span class="extract-syntax">NULL</span></span>, and the result could be horribly inconsistent.
So the function should be used only with great care.
</p>

<p class="commentary">Note that the name is not removed from the dictionary (if the table has one).
This means that textual lookups on it might still return <span class="extract"><span class="extract-syntax">S</span></span>: so, again, do
not use the function if that is able to cause problems.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::remove_symbol</span><button class="popup" onclick="togglePopup('usagePopup21')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup21">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::remove_symbol</span></span>:<br/>Transmigration - <a href="2-trn.html#SP3_3">&#167;3.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_symbol</span><span class="plain-syntax"> *</span><span class="identifier-syntax">S</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">index</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_ID</span><span class="plain-syntax"> - (</span><span class="reserved-syntax">int</span><span class="plain-syntax">) </span><span class="constant-syntax">SYMBOL_BASE_VAL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><a href="2-tw2.html#SP5" class="function-link"><span class="function-syntax">Wiring::wire_to</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">S</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">S</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">owning_table</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">symbol_array</span><span class="plain-syntax">[</span><span class="identifier-syntax">index</span><span class="plain-syntax">] = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. Logging.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterSymbolsTable::log</span><button class="popup" onclick="togglePopup('usagePopup22')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup22">Usage of <span class="code-font"><span class="function-syntax">InterSymbolsTable::log</span></span>:<br/>Bytecode Module - <a href="1-bm.html#SP3_4">&#167;3.4</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">vst</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">ST</span><span class="plain-syntax"> = (</span><span class="reserved-syntax">inter_symbols_table</span><span class="plain-syntax"> *) </span><span class="identifier-syntax">vst</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ST</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;null-stable&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&lt;%d:"</span><span class="plain-syntax">, </span><span class="identifier-syntax">ST</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">allocation_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">inter_package</span><span class="plain-syntax"> *</span><span class="identifier-syntax">P</span><span class="plain-syntax"> = </span><a href="2-st.html#SP3" class="function-link"><span class="function-syntax">InterSymbolsTable::package</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">ST</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">P</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"(root)"</span><span class="plain-syntax">); </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"$6"</span><span class="plain-syntax">, </span><span class="identifier-syntax">P</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"&gt;"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="2-inl.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-bm.html">1</a></li><li class="progresscurrentchapter">2</li><li class="progresssection"><a href="2-it.html">it</a></li><li class="progresssection"><a href="2-in.html">in</a></li><li class="progresssection"><a href="2-bkm.html">bkm</a></li><li class="progresssection"><a href="2-np.html">np</a></li><li class="progresssection"><a href="2-tw.html">tw</a></li><li class="progresssection"><a href="2-pck.html">pck</a></li><li class="progresssection"><a href="2-inl.html">inl</a></li><li class="progresscurrent">st</li><li class="progresssection"><a href="2-sym.html">sym</a></li><li class="progresssection"><a href="2-ann.html">ann</a></li><li class="progresssection"><a href="2-tw2.html">tw2</a></li><li class="progresssection"><a href="2-trn.html">trn</a></li><li class="progresschapter"><a href="3-ic.html">3</a></li><li class="progresschapter"><a href="4-tcc.html">4</a></li><li class="progresschapter"><a href="5-tac.html">5</a></li><li class="progresschapter"><a href="6-tpc.html">6</a></li><li class="progressnext"><a href="2-sym.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

